home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / util / boot / ShellUpdate.lha / Documentation / Ask next >
Text File  |  2001-12-25  |  2KB  |  68 lines

  1. Ask
  2.  
  3. Format:        ASK <prompt> [TO=<var>] [NUMERIC] [STRING]
  4. Template:    PROMPT/A,TO/K,NUMERIC/S,STRING/S
  5. Purpose:    To obtain user inut when executing a script file
  6. Path:        Internal
  7. Specification:    ASK is used in scripts to write the <prompt> to the
  8.     current window, then wait for keyboard input. Depending on 
  9.     the options, valid inputs are either Y (yes), Return = N (no),
  10.     a number, or any string. Without any further options, ASK signals
  11.     the return code 5 (WARN) for Y, and 0 for N. An IF WARN statement
  12.     can be used to check this kind of response. For numeric and 
  13.     string input, the user input is printed onto the current window.
  14.     Alternatively, ASK may set a local variable to the user input.
  15.     If the PROMPT contains spaces, it should be enclosed in double
  16.     quotes.
  17.  
  18. Without the TO, NUMERIC and STRING arguments, ASK expects a boolean input
  19. of the type "Y" or "YES" resp. "N" or "NO" or Return (no input) and sets
  20. the condition codes accoringly: 5 (WARN) for "Y" and 0 otherwise.
  21.  
  22. If the TO option has been specified, ASK expects the name of a local
  23. variable without $ sign and sets this variable to "1" for YES and to "0"
  24. for NO.
  25.  
  26. If the NUMERIC keyword has been found, ASK expects the user to input a
  27. decimal number. This number is either printed onto the current output,
  28. or if the name of a local variable has been specified with the TO option,
  29. this variable is set to the user input.
  30.  
  31. If the STRING keyword is found on the input, ASK expects the user to input
  32. a string of any kind. Similar to the above, this string is either printed
  33. to the current output, or placed into the variable given by the TO keyword.
  34.  
  35. Examples:
  36.  
  37. Assume a script contained the following commands:
  38.  
  39. ASK Continue?
  40. IF WARN
  41.     ECHO Yes
  42. ELSE
  43.     ECHO No
  44. ENDIF
  45.  
  46. When the ASK command is reached, "Continue?" will appear on the screen. If
  47. Y is pressed, "Yes" will be displayed on the screen. If N is pressed, "No"
  48. will be displayed.
  49.  
  50. The following script will ask the user for a number, and will print this
  51. number onto the output window:
  52.  
  53. ASK NUMERIC "Enter a number:" TO num
  54. ECHO $num
  55.  
  56. ASK will continue to display its prompt until a valid number is found,
  57. which will then be put into the variable num. Note that ASK expects the
  58. variable name without a $ sign in front.
  59.  
  60.  
  61. The next example will ask the user for a file name, and will then display
  62. the contents of this file on the console:
  63.  
  64. ASK STRING "Enter a file name to display:" TO file
  65. TYPE $file
  66.  
  67. See also: IF, SET
  68.